//
//  ActiveDetailsViewController.m
//  豆瓣zlw
//
//  Created by lanou3g on 16/1/8.
//  Copyright © 2016年 zlw. All rights reserved.
//

#import "ActiveDetailsViewController.h"
#import <UIImageView+WebCache.h>
#import "ActiveModel.h"
#import "LoginViewController.h"
#import "DataBase.h"

@interface ActiveDetailsViewController ()

@end

@implementation ActiveDetailsViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title=self.getmodel.title;

    self.getTitle.text=self.getmodel.title;
    [self.getImV sd_setImageWithURL:[NSURL URLWithString:self.getmodel.image] ];
    self.getBegin_time.text=self.getmodel.begin_time;
    self.getEnd_time.text=self.getmodel.end_time;
    self.getCategory_name.text=self.getmodel.category_name;
    self.getName.text=self.getmodel.name;
    self.getAdress.text=self.getmodel.address;
    self.getContent.text=self.getmodel.content;
    

    
    
  //隐藏菊花
     [self.HUD hide:YES];
    
}

- (IBAction)ActiveDe__back:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}
- (IBAction)ActiveDe__Share:(id)sender {
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
   
 
    if ([defaults boolForKey:@"User"])
    {
        //打开数据库
        [[DataBase shareData] openData];
        //存放数据
        ActiveModel *act=[[ActiveModel alloc] init];
        act.title=self.getmodel.title;
        act.begin_time=self.getmodel.begin_time;
        act.end_time=self.getmodel.end_time;
        act.address=self.getmodel.address;
        act.participant_count=self.getmodel.participant_count;
        act.wisher_count=self.getmodel.wisher_count;
        act.image=self.getmodel.image;
        act.name=self.getmodel.name;
        act.category_name=self.getmodel.category_name;
        act.content=self.getmodel.content;
        [[DataBase shareData] addActive:act];

        //关闭数据库
        [[DataBase shareData] closeData];
        
        //显示UIAlertView提示用户
      UIAlertView * alertView = [self showAlertViewWithTitle:@"提示" message:@"收藏成功" cancelButtonTitle:nil otherButtonTitle:nil];
        
     //0.3秒后消失
        [self performSelector:@selector(removeAlertView:) withObject:alertView afterDelay:1];
        
        
    }else
    {
        LoginViewController *VC=[[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MinLog"];
        [self.navigationController pushViewController:VC animated:YES];
        
    }
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
